package com.swak.fx.support;

import org.controlsfx.glyphfont.FontAwesome;

import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import lombok.Getter;

/**
 * 创建快捷的动作
 * 
 * @author 618lf
 */
@Getter
public class Action {
	private final ObjectProperty<FontAwesome.Glyph> glyphProperty = new SimpleObjectProperty<>();// 图标
	private final StringProperty textProperty = new SimpleStringProperty(); // 默认文本
	private final BooleanProperty visableProperty = new SimpleBooleanProperty(true); // 是否可见
	private final BooleanProperty activeProperty = new SimpleBooleanProperty(false); // 是否激活
	private final StringProperty activeTextProperty = new SimpleStringProperty();// 激活文本
	private final ObjectProperty<Object> commandProperty = new SimpleObjectProperty<>();// 命令

	public FontAwesome.Glyph getGlyph() {
		return glyphProperty.get();
	}

	public String getText() {
		return textProperty.get();
	}

	public Boolean isVisable() {
		return visableProperty.get();
	}

	public Boolean isActive() {
		return activeProperty.get();
	}

	public String getActiveText() {
		return activeTextProperty.get();
	}

	public Object getCommand() {
		return commandProperty.get();
	}

	public Action setGlyph(FontAwesome.Glyph glyph) {
		glyphProperty.set(glyph);
		return this;
	}

	public Action setText(String text) {
		textProperty.set(text);
		return this;
	}

	public Action setVisable(boolean bol) {
		visableProperty.set(bol);
		return this;
	}

	public Action setActive(boolean bol) {
		activeProperty.set(bol);
		return this;
	}

	public Action setActiveText(String text) {
		activeTextProperty.set(text);
		return this;
	}

	public Action setCommand(Object command) {
		commandProperty.set(command);
		return this;
	}

	public Action bindVisable(BooleanBinding binding) {
		visableProperty.bind(binding);
		return this;
	}

	public Action bindActive(BooleanBinding binding) {
		activeProperty.bind(binding);
		return this;
	}

	public static Action of() {
		return new Action();
	}
}
